package com.ccbft.msgcenter.mc.filter.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.ccbft.msgcenter.mc.filter.entity.Filter;
import com.ccbft.msgcenter.mc.filter.service.IFilterService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author frank
 * @since 2019-07-20
 */
@RestController
@RequestMapping("/filters")
public class FilterController {
	
	@Autowired
	private IFilterService filterService;
	
	@RequestMapping(method=RequestMethod.POST, consumes = "application/json")
	public boolean add(@RequestBody Filter filter) {
		return filterService.save(filter);
	}
	
	@RequestMapping(value="/{id}", method=RequestMethod.DELETE)
	public boolean deleteById(@PathVariable("id") Long id) {
		return filterService.removeById(id);
	}
	
	@RequestMapping(method=RequestMethod.GET )
	public List<Filter> queryAll(){
		return filterService.list();
	}
	
	@RequestMapping(value="/{id}", method=RequestMethod.GET)
	public Filter queryById(@PathVariable("id") Long id) {
		return filterService.getById(id);
	}
	
	@RequestMapping(value="/{id}", method=RequestMethod.PUT)
	public boolean updateById(@PathVariable("id") Long id,@RequestBody Filter entity) {
		entity.setId(id);
		return filterService.updateById(entity);
	}
}
